package com;

import com.softkey.jsyunew3;

public class SoftKey2 {

    com.softkey.jsyunew3 j9;

    SoftKey2() {
        j9 = new com.softkey.jsyunew3();
    }

    private String myhex(byte indata) {
        String outString;
        outString = String.format("%X", indata);
        if (outString.length() < 2) outString = "0" + outString;
        return outString;
    }

    //若某字节为负数则需将其转成无符号正数
    private long conver(byte temp) {
        long tempInt = (int) temp;
        if (tempInt < 0) {
            tempInt += 256;
        }
        return tempInt;
    }

    //以下用于将16进制字符串转化为无符号长整型
    private int HexToInt(String s) {
        String[] hexch = {"0", "1", "2", "3", "4", "5", "6", "7",
                "8", "9", "A", "B", "C", "D", "E", "F"};
        int i, j;
        int r, n, k;
        String ch;

        k = 1;
        r = 0;
        for (i = s.length(); i > 0; i--) {
            ch = s.substring(i - 1, i - 1 + 1);
            n = 0;
            for (j = 0; j < 16; j++) {
                if (ch.compareToIgnoreCase(hexch[j]) == 0) {
                    n = j;
                }
            }
            r += (n * k);
            k *= 16;
        }
        return r;
    }


    public String StrEnc(String InString, String Key)//使用增强算法，加密字符串
    {

        byte[] b, outb;
        byte[] temp_b = InString.getBytes();
        byte[] temp = new byte[8], outtemp = new byte[8];
        int n, i, nlen, outlen;
        String outString;

        nlen = temp_b.length;
        nlen = nlen + 1;
        if (nlen < 8)
            outlen = 8;
        else
            outlen = nlen;
        b = new byte[outlen];
        outb = new byte[outlen];

        for (n = 0; n < nlen - 1; n++) {
            b[n] = temp_b[n];
        }

        outb = b.clone();

        for (n = 0; n <= outlen - 8; n = n + 8) {
            for (i = 0; i < 8; i++) temp[i] = b[i + n];
            EnCode(temp, outtemp, Key);
            for (i = 0; i < 8; i++) outb[i + n] = outtemp[i];
        }

        outString = "";
        for (n = 0; n <= outlen - 1; n++) {
            outString = outString + myhex(outb[n]);
        }
        return outString;
    }

    public String StrDec(String InString, String Key)//使用增强算法，解密字符串
    {

        byte[] b, outb;
        byte[] temp = new byte[8], outtemp = new byte[8];
        int n, i, nlen, outlen;
        String outString, temp_String;


        nlen = InString.length();
        if (nlen < 16) outlen = 16;
        outlen = nlen / 2;
        b = new byte[outlen];
        outb = new byte[outlen];

        i = 0;
        for (n = 1; n <= nlen; n = n + 2) {
            temp_String = InString.substring(n - 1, n - 1 + 2);
            b[i] = (byte) HexToInt(temp_String);
            i = i + 1;
        }

        outb = b.clone();

        for (n = 0; n <= outlen - 8; n = n + 8) {
            for (i = 0; i < 8; i++) temp[i] = b[i + n];
            DeCode(temp, outtemp, Key);
            for (i = 0; i < 8; i++) outb[i + n] = outtemp[i];
        }

        outString = new String(outb);
        outString = outString.trim();
        return outString;
    }

    public void EnCode(byte[] inb, byte[] outb, String Key) {

        long cnDelta, y, z, a, b, c, d, temp_2;
        long[] buf = new long[16];
        int n, i, nlen;
        long sum;
        long temp, temp_1;
        long mask = 4294967295L;

        //UInt32 temp, temp_1;
        String temp_String;


        cnDelta = 2654435769L;
        sum = 0;

        nlen = Key.length();
        i = 0;
        for (n = 1; n <= nlen; n = n + 2) {
            temp_String = Key.substring(n - 1, n - 1 + 2);
            buf[i] = HexToInt(temp_String);
            i = i + 1;
        }
        a = 0;
        b = 0;
        c = 0;
        d = 0;
        for (n = 0; n <= 3; n++) {
            a = (buf[n] << (n * 8)) | a;
            b = (buf[n + 4] << (n * 8)) | b;
            c = (buf[n + 4 + 4] << (n * 8)) | c;
            d = (buf[n + 4 + 4 + 4] << (n * 8)) | d;
        }


        y = 0;
        z = 0;
        for (n = 0; n <= 3; n++) {
            temp_2 = conver(inb[n]);
            y = (temp_2 << (n * 8)) | y;
            temp_2 = conver(inb[n + 4]);
            z = (temp_2 << (n * 8)) | z;
        }


        n = 32;

        while (n > 0) {
            sum = (cnDelta + sum) & mask;

            temp = (z << 4) & mask;
            temp = (temp + a) & mask;
            temp_1 = (z + sum) & mask;
            temp = (temp ^ temp_1) & mask;
            temp_1 = (z >> 5) & mask;
            temp_1 = (temp_1 + b) & mask;
            temp = (temp ^ temp_1) & mask;
            temp = (temp + y) & mask;
            y = temp & mask;
            /*y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); */

            temp = (y << 4) & mask;
            temp = (temp + c) & mask;
            temp_1 = (y + sum) & mask;
            temp = (temp ^ temp_1) & mask;
            temp_1 = (y >> 5) & mask;
            temp_1 = (temp_1 + d) & mask;
            temp = (temp ^ temp_1) & mask;
            temp = (z + temp) & mask;
            z = temp & mask;
            /* z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); */
            n = n - 1;

        }
        for (n = 0; n <= 3; n++) {
            outb[n] = (byte) ((y >>> (n * 8)) & 255);
            outb[n + 4] = (byte) ((z >>> (n * 8)) & 255);
        }
    }

    public void DeCode(byte[] inb, byte[] outb, String Key) {

        long cnDelta, y, z, a, b, c, d, temp_2;
        long[] buf = new long[16];
        int n, i, nlen;
        long sum;
        long temp, temp_1;

        long mask = 4294967295L;

        //UInt32 temp, temp_1;
        String temp_String;


        cnDelta = 2654435769L;
        sum = 3337565984L;

        nlen = Key.length();
        i = 0;
        for (n = 1; n <= nlen; n = n + 2) {
            temp_String = Key.substring(n - 1, n - 1 + 2);
            buf[i] = HexToInt(temp_String);
            i = i + 1;
        }
        a = 0;
        b = 0;
        c = 0;
        d = 0;
        for (n = 0; n <= 3; n++) {
            a = (buf[n] << (n * 8)) | a;
            b = (buf[n + 4] << (n * 8)) | b;
            c = (buf[n + 4 + 4] << (n * 8)) | c;
            d = (buf[n + 4 + 4 + 4] << (n * 8)) | d;
        }


        y = 0;
        z = 0;
        for (n = 0; n <= 3; n++) {
            temp_2 = conver(inb[n]);
            y = (temp_2 << (n * 8)) | y;
            temp_2 = conver(inb[n + 4]);
            z = (temp_2 << (n * 8)) | z;
        }


        n = 32;

        while (n > 0) {


            temp = (y << 4) & mask;
            temp = (temp + c) & mask;
            temp_1 = (y + sum) & mask;
            temp = (temp ^ temp_1) & mask;
            temp_1 = (y >> 5) & mask;
            temp_1 = (temp_1 + d) & mask;
            temp = (temp ^ temp_1) & mask;
            temp = (z - temp) & mask;
            z = temp & mask;
            /* z += ((y << 4) + c) ^ (y + sum) ^ ((y >> 5) + d); */

            temp = (z << 4) & mask;
            temp = (temp + a) & mask;
            temp_1 = (z + sum) & mask;
            temp = (temp ^ temp_1) & mask;
            temp_1 = (z >> 5) & mask;
            temp_1 = (temp_1 + b) & mask;
            temp = (temp ^ temp_1) & mask;
            temp = (y - temp) & mask;
            y = temp & mask;
            /*y += ((z << 4) + a) ^ (z + sum) ^ ((z >> 5) + b); */

            sum = (sum - cnDelta) & mask;
            n = n - 1;

        }
        for (n = 0; n <= 3; n++) {
            outb[n] = (byte) ((y >>> (n * 8)) & 255);
            outb[n + 4] = (byte) ((z >>> (n * 8)) & 255);
        }
    }

    public long get_LastError() {
        return j9.get_LastError();
    }

    public String FindPort(int start) {
        return j9.FindPort(start);
    }


    //使用带长度的方法从指定的地址读取字符串
    private String ReadStringEx(int addr, String DevicePath) {
        int nlen, ret;
        byte[] buf = new byte[1];
        //先从地址0读到以前写入的字符串的长度
        ret = j9.YReadEx((short) addr, (short) 1, "6ABA31BA", "BDE13217", DevicePath);
        if (ret != 0) return "";
        nlen = j9.GetBuf(0);
        //再读取相应长度的字符串
        return j9.NewReadString(addr + 1, nlen, "6ABA31BA", "BDE13217", DevicePath);

    }

    //使用从储存器读取相应数据的方式检查是否存在指定的加密锁
    public int CheckKeyByReadEprom() {
        int n, ret;
        String DevicePath = "";//用于储存加密锁所在的路径
        String outString = "";
        //@NoUseCode_data return 1;//如果没有使用这个功能，直接返回1
        for (n = 0; n < 255; n++) {
            DevicePath = j9.FindPort(n);
            if (j9.get_LastError() != 0) return (int) j9.get_LastError();
            outString = ReadStringEx(0, DevicePath);
            if ((j9.get_LastError() == 0) && (outString.compareTo("03948F7172394F4F3978C9DE7B7EF378") == 0)) return 0;
        }
        return -92;
    }

    //使用增强算法一检查加密锁，
    public int CheckKeyByEncstring() {
        int n, ret;
        String DevicePath = "";//用于储存加密锁所在的路径
        String outString = "";
        int myrnd = (int) (Math.random() * 500);
        String[] EncInString = {"26217", "19710", "18668", "32280", "15283", "25482", "25105", "15440", "1043", "8531", "1023", "25779", "114", "27548", "1772", "22162", "23259", "27718", "30004", "23264", "122", "981", "13650", "9775", "7062", "23400", "21471", "31408", "11674", "5828",
                "28053", "27190", "18704", "9801", "14670", "14387", "27554", "14585", "12805", "23480", "30747", "20087", "24786", "8568", "20580", "26885", "18160", "28100", "3975", "24452", "26554", "7823", "25518", "20343", "29352", "3435", "2083", "12032", "3415", "12681",
                "24400", "32480", "15742", "25020", "11456", "7291", "29432", "13941", "28443", "13264", "12735", "3016", "23085", "20867", "23533", "9061", "28894", "5334", "7102", "26269", "16186", "427", "28040", "18534", "13418", "29314", "18888", "18254", "7353", "10880",
                "28438", "3978", "15247", "1894", "19503", "15594", "1399", "21396", "2538", "15584", "31259", "14351", "13634", "20607", "7750", "20087", "2386", "11897", "5601", "21263", "22866", "17695", "24053", "30392", "6814", "7269", "9903", "20725", "3759", "22490",
                "19798", "29160", "3359", "22706", "30292", "5203", "28071", "32703", "18230", "28566", "4644", "3955", "16548", "10678", "4237", "11743", "14439", "26963", "31997", "1718", "29547", "1969", "21423", "3401", "24505", "25262", "764", "24203", "28283", "20177",
                "5470", "17165", "3579", "10553", "31598", "20739", "17315", "2472", "30184", "11837", "26109", "5249", "8102", "29229", "30388", "27845", "6048", "10214", "7313", "17943", "19185", "28698", "15741", "5818", "24275", "17178", "14468", "27020", "15009", "21209",
                "16335", "20500", "12756", "3305", "21160", "29808", "19974", "15483", "22393", "19301", "14577", "19554", "21965", "26194", "18031", "10512", "20556", "25916", "7803", "17046", "16066", "2244", "1837", "11943", "10264", "25642", "20160", "27284", "23639", "12115",
                "21903", "15696", "20139", "14527", "14355", "14701", "3934", "30608", "6374", "24348", "26072", "15754", "2754", "24111", "2725", "2317", "6785", "30746", "365", "30491", "31005", "494", "4860", "21847", "17841", "1628", "26426", "21507", "30581", "1974",
                "16179", "22529", "26565", "25070", "20240", "27858", "31769", "19608", "14363", "22168", "28685", "31972", "8894", "17431", "16219", "26533", "30851", "8367", "12251", "9037", "15893", "1635", "31624", "27117", "3389", "20435", "6781", "15160", "12004", "19012",
                "11506", "7807", "21782", "1943", "1347", "1206", "29948", "20557", "20968", "19052", "16608", "13705", "26493", "22997", "16940", "17164", "10940", "27843", "4971", "20793", "6781", "28327", "14917", "30481", "31163", "32404", "8582", "7224", "6545", "4413",
                "13079", "10990", "17207", "13041", "4610", "25109", "16905", "27043", "29808", "18224", "3456", "14055", "7598", "14433", "4918", "14830", "30754", "7785", "8421", "29064", "20314", "16043", "28262", "7722", "10750", "11561", "18358", "17380", "17367", "24195",
                "22252", "19561", "10193", "23038", "3652", "18698", "27124", "2939", "12823", "21690", "365", "13691", "735", "5643", "17027", "801", "1846", "24878", "30881", "14894", "30165", "31222", "8274", "3333", "16280", "30164", "16702", "3240", "14713", "15836",
                "26672", "15032", "26256", "12477", "16659", "15224", "25112", "25803", "20720", "10185", "26988", "2553", "20465", "32558", "1541", "27606", "9056", "14793", "22397", "5015", "30631", "31323", "32141", "2572", "31312", "24647", "8722", "14759", "13318", "31118",
                "8964", "28795", "658", "21716", "23676", "570", "13022", "13145", "4790", "2614", "15091", "23295", "31754", "19807", "5118", "2122", "27379", "15434", "13382", "89", "6157", "5416", "10550", "17136", "3087", "9673", "20824", "23665", "10708", "11682",
                "13911", "22494", "22614", "24514", "1788", "20696", "19632", "1247", "12592", "9634", "29722", "15687", "7167", "18717", "32239", "25326", "402", "13516", "1451", "2918", "26930", "31440", "23780", "10720", "16716", "30701", "30039", "20783", "6504", "9603",
                "27357", "5573", "31790", "2965", "11633", "4019", "26988", "21188", "19243", "31915", "28682", "30290", "23111", "513", "26642", "5668", "798", "3749", "19630", "26807", "10794", "23849", "13864", "19761", "14852", "5569", "29674", "32082", "3433", "4157",
                "18047", "24445", "31023", "13839", "14735", "30899", "30291", "1098", "7654", "32408", "27631", "11680", "9069", "2412", "6460", "23650", "4910", "26129", "8084", "5251"};
        String[] EncOutString = {"0AF445723ABFEDB5", "9B09982079D26133", "78D5FF862D272C47", "B658790C9A2737F1", "8D109484161319F1", "7CBE51D2F97DEBED", "1586553EAFDB8111", "24145A8187D2AAFF", "BB8584A413F21D15", "0FC20338D867E34A", "40F31C86DE0C8AEC", "4708E2145095BA65", "71C8C059FC1E617E", "264D606B44A4D05F", "7AB23B10E351ED2A", "EE9E000A4EB11030", "9A3D0BA076CED96F", "03EA4A5B321BFC7A", "07CFB80B06DB9DDA", "DEE5AB01BBF04C88", "2F1A837F94541FA1", "7AA89949C8FE136D", "7CF511C2D2235723", "0C42D3A4263C56F4", "0F1D2A940428AFB0", "EDB4C35D6D6ED079", "033FC2B46141ECBC", "26261862CBEA87EA", "616408A097967057", "B51EAD378CAD7F29",
                "08C580257DF039F0", "0448CC3D3AB88C90", "03F84EAE4A698CAD", "26E61C889AABA496", "E4E572E2EB88F6E3", "190B99F908D69170", "4C1FB00C3E0B6D9F", "5A77803B346886F0", "4E35E46C4B8142B1", "6082939AFC75FE53", "8105C037E08C1505", "FC3A40F4CCEA5016", "68B8549A317DB40D", "C7AE250DB475FD9A", "654A6E718F1ED4B5", "3735A913F8BC9A17", "11F899DC66AF2B2D", "9C135AD25DA4A9E9", "00050886E5263237", "942F47D7DE749187", "4B351CB3CAB3BE0C", "67349AF1C4E64737", "E0F6DBCA70B26444", "2DF9C30D03416891", "4FD332AE5C5B67AF", "E69D85639BD95BDC", "1BBEFA6B72F54C9D", "1B8CA325AB90F68C", "FF9BB929B9CFF950", "82FD0F29D6702F7A",
                "AFC1F01C198CC50A", "67ACC846B236780F", "EF16FDD5CD9F8FC9", "641039D05BC89F93", "05D27305D41910C0", "B4E73A283701DCB7", "324F7A726076C9CC", "B89CE2E919D9A477", "593588F10535096C", "8B5C7C3FCE4B75DC", "F411734955F8F3B1", "A2CFF7B9EE986851", "E14902E34499FA12", "0F19F134853E5935", "EF01ABB20BDBB68E", "9FA7AC15C1FB17D5", "2C465FA62D1084C8", "728CF3A854D23439", "3B396900569F6304", "CD010397E7E753E3", "7512D194C4E5A1B0", "EC44200ECD5B2734", "95D1BE5F88CAA32D", "CF33F4D9B6D15AE4", "CAFB750ED60A6FA1", "24D1985BDECCE24A", "B8E5E1C8EF865F06", "756730C7F10FEEA8", "3EBA26BD315E1E80", "0F85C9D0AC16B3C6",
                "17EB8776CB46DEB9", "99ACAC69CE96C3D4", "BAA67115EF81B1E7", "50AF19A89493904A", "D3191F139BCAC884", "17B1AB279D52718F", "499D01E3F6FE0666", "C52065D477E1D8A1", "6C51C7B67F94F954", "7E6D9737D8271D09", "16B43122BE306CF8", "4AE5554ECBBCD388", "4EC39CA31202A1BE", "D56BE3FB38531D9C", "7F7D287BDF0839EC", "FC3A40F4CCEA5016", "B0BE37FF50986429", "6A3BD11A106A07BF", "03E43326B37FD5F9", "FE7A67BC520C943D", "FCF3829E99364A0D", "C920F67CAF049F29", "E8742D5EAC9F77FB", "58B2E3E6E46972DF", "05C0A078516ACF97", "1DDF550B8A110802", "FD054802330055E2", "B33C6961AB637AAD", "A5F2AC3B6C3F1072", "09850F297A04D1C8",
                "0D974F67E71C98DB", "99DC3515C094365E", "4FC0D99A7A02A1DD", "E4A92C9CF175C8BE", "5FAD4EBAEC883AFA", "20556B0359B81342", "8A379C2D3D288731", "5D1DA1AD33796A2D", "0EDD79E939497659", "C5F41AF8B4493739", "97CD5EB70E14875A", "9B8D840F32BEA6BB", "8E4B19C0F918186C", "4E19201A9B79C281", "1CF7A5448D141ED9", "E437FF4B210AA84B", "87FFEB60E3B68BC6", "506AE0A6B055ECDE", "F36643C53E920367", "2320DE37EC7C28A9", "5D9A6B9915438385", "F705262D77615FCB", "43114387ADB21C5F", "D80DD8DDC1087A9F", "0113406802E0C13A", "900B481C5C0AA4F2", "15BE01648D27CEDE", "1FC3A7964D50066F", "0C53CB53027FDB11", "EA8158D5215D089E",
                "FDB628850E01A19C", "768AC143DD125273", "6A0EB246793C0EDD", "2E4BCCB44E59A735", "130FABBF4D0E9C9B", "F08D790A7FE935C2", "9F4FB2A792002A80", "C0B1AB9F84266F8E", "5580E3ABFD009648", "3E7A36CCE9391A7D", "BA55CDF75CE07F9D", "60930150ED6F444D", "712212509F5A026A", "98F3D9B587C87BAE", "7E625EB224F12520", "D4AAB4E14447E9BC", "F3646A6E75AB30D9", "1A1637EED90BEB46", "976C68886F96FC50", "95273F8614D5EDE6", "FBBBD75E99E1B067", "B39D9F7A17A680DE", "2709A12EBBFF8404", "7C2055D4B6DC6F4D", "778904CE7E41DE68", "8B93F899666EE3A8", "18E0F8BC8BDF2A3C", "47D5AA9D8D7040C0", "7E776DFED557EE8B", "FD6FE2AC8B0BCF19",
                "AA915F682210C658", "A067E03F693378B7", "564344716B76ACEB", "47E47F917C773FA9", "2D6BDE47747739AF", "BA5255B1437EB5BF", "F0F2E399DCB2ADEF", "58B501B0E95498B1", "66055E69AD0E6C2A", "6C04ECE39CB7C55A", "FAC2C8266E15E9BF", "389D009A078B6A83", "5FFC85723869651A", "2C10D80BEF8AC143", "4C0919AB779C370C", "A0081A32F9E1AA56", "39BF739801578F44", "760387A7493B43C9", "31875BEEBF6DB07A", "6A36D55B815633A0", "4F711DE7741CD69B", "B429465955773F04", "D9B3E82E172D57EE", "51C01652F2FAE82A", "82A78ECDF21FB66A", "8D0DB603788679F0", "B7F23B2BBCFA731B", "105D89893EE2227B", "4EBE7960ECC0903A", "573C9AF3348E43FD",
                "8D3D77E360D02048", "946AC86D127E074E", "07B703F21BA8BC0B", "2277173B243C1430", "730548F2F90EB044", "3FC60754A1FBF9B2", "F491B64568BC9F3D", "D9CD13A988911327", "6E3BCCE46E399A7E", "F33A9B1208AF54D4", "C3372C919F196D89", "2DB89069BB7324B5", "1DE8D6DBE842BF31", "BAC7083B01EFF907", "1682C8B878011F7D", "B00C97B1922088E2", "5D8A5E39514E171F", "1D641BF8E2F0BE0A", "7E631C53AA54DC45", "163B87513CD755B3", "229735A38DD679E2", "22F10F17B175A58B", "B99819D0F6728AA5", "30DA19DD43DBEF27", "B8D955E65FF801D6", "4D1AA38AC964E4DE", "F4FB28A6F5B3BC90", "0C8BF6DD75D41347", "81143E0518C92617", "A968FB52EF2CC272",
                "E50F8CBD81C77A7E", "02F7DA0245B38628", "7116A7A1DDBE3209", "E9F1D5B4527FF868", "E5053ACCA5EABB4C", "37E49CF1E8A29A2D", "BB91090ACF429E87", "83FCC09C8C485BA7", "558A0B03FCACD28E", "82E92DDF59B6EAB6", "AA44A3ECA4DF7FC3", "2E46157272A779D7", "066C3661547DA191", "2BF77D78C7E28876", "23C190E3D625DF08", "DAA2BF28478E30A3", "A7ACF9B60E96536E", "C3279326ABE4715A", "2F43FB86B0A2C4BA", "0B43EB447A67C6F1", "28D498B0A0C77B7C", "45BE79015C30BD51", "F83D10B54133B927", "49E811CAF12B0146", "078D5B9E1238ABDB", "FFE72E38C3F53AA0", "0A55FDBE7E1AEFC5", "E23DD14B789C3A90", "39EC9EA3CBB8432F", "A9406E93237737F5",
                "75C2CF6203CB8500", "8E33CA678897FC50", "885FF355573EA065", "18BB0AC0981001AF", "4F689CA030508C56", "2970B98313643CB1", "0191F47362DDAEC1", "EBF952EE7D3790D5", "D73A115801FF96BF", "858A5AD66D3C5E6D", "CF2EDB0B3FD543BC", "C5D93F5AF0EFA1E0", "6A8A8E1934925B2D", "92871C2BCB27D3DA", "4C14D951958901D9", "1A925D2E8FA1F1C2", "7C34873CFE4F4AA4", "D1178FB89E9CACCB", "D3088963029DFF78", "FBE380594157A88A", "0A55FDBE7E1AEFC5", "68E3CE0FA19E5B83", "AFD1D18E5AA60F40", "49E60D7B573EAC53", "C7482893F4A67660", "B59E3BEF3E5A2DE0", "08C85261C2944986", "26C7C42638D3BBA7", "53AB5B91DD9A04F5", "A2F62EDD6F4840AA",
                "4DE36F07B268B542", "F0825F7285EDE367", "30B6F3131C2BD0E3", "86D09153A36324DA", "90B32E14DCC7ADB9", "614B3E987A206FF0", "9DD56B2797E97B6E", "659AB04F43E827E1", "BA5255B1437EB5BF", "9BFF167F9D30E595", "0939912348086EAD", "F4F6B5A829084DD3", "4B6D9F23ACBCDE3F", "6DEA06B7F770D4D2", "33761DE5A343F09A", "A7699B34F27081D5", "EC97D53FBDEE6A42", "D06D0105166CF185", "BFC0F4EFCBE6561C", "71E1F6C348D4BA71", "CE094722F2056D32", "89AAF326EF0F7754", "112FE51747DA2C2D", "56D4CC280615CF02", "EAAEBC58807075A0", "46423839E93BBFEF", "B20E1C9B4C3F07BC", "F225751347CCC8CB", "0C20616181E40989", "ED1FA35F9FFF9B7F",
                "449238840B7146EE", "0A45279F92ABAFCE", "0730B887C9178141", "36D44A91AA698DAC", "C20AF59ADDB95E15", "F9A23493C78B8C72", "832B7FF144508114", "B5DB46425457E981", "C9D94684511914C0", "4D5F66327243AB8D", "7E631C53AA54DC45", "B20998998C34FCAD", "7AE9C55105661FA6", "B86079FAB7DF1197", "1A4C94EC2838F964", "A30CCBA3D0620D63", "DE7C0118952656A2", "0FF3571DEA928484", "5A71A94A0401C306", "A3711F31D59C1C00", "64C77D557EF50897", "9DDDE91A9A48F261", "64BFC075CA0D8BAB", "8D98796DE9DED525", "C2C2A78653207A8A", "452253D25E87DB02", "DE7A08DA39B0B050", "4F606B6AABDC92A4", "6DA558E5F8EBD4C0", "8644DD9BD26B3503",
                "54A0507AE8CA9DED", "5F81E89CDD35BBC6", "B3A1226C5BB9FDCF", "988EEE845CDF2BB1", "96BE9AB812C7FDC8", "FAC832CA885B2F86", "0C015F45505D7BE0", "E529050B9CF33612", "4E75D5AF357E214C", "07F6376F59543050", "012363BE7AF97F6C", "7849BD6EFCE100D8", "F1AAA74FC7A64CAE", "7A37178A3B28D9EF", "D733D2C30978A8BE", "73A877DCC0C47CDD", "CAC3138AB840AA22", "B0DC250268571814", "E856892E9DC00F76", "9890CE1C58C0F5D5", "D4FEC7A9B7C91717", "D6314430C1330E6D", "D15F067349710D7A", "90F93061113B2B8D", "7BDCFA49DF1B4BD4", "9B7E2C1A6C399D80", "8FCE9DC8D70A2F85", "5B71BEAE21F171CF", "A135FEC5D933F39C", "FD8342C193242923",
                "64202AA03A460E57", "CA63215AC7D522D1", "EFA08589D06C85F3", "2AB2C2A9370121F6", "78E0CD803D44CA0D", "DE06B1EA6E643AD5", "429DC40D48B5DF4C", "E8F4A9A93FD6F7C0", "3C626DD378FD7A99", "8ACBB9CBFB8ED8BF", "15FF79596E0E4D61", "50BE1C9D88E0880F", "D0C3D0F8E7F07EA9", "F36DAA36E59BED79", "92451CA26FE9BA6B", "FA52AE81F960B12E", "C52271C6967E93A2", "4BE53465519EAD91", "C187F8633E74512C", "65FFB38BA5C41FC3", "1AC99908FFB21DE3", "CA719DD20AD3EC56", "AE352D3B7A668C36", "8B6D757CCBE97B16", "CE16EC8A428605BD", "F3F6F989D42BF2A6", "9287CB1FEBD4FB12", "A1D8D11168CE9EE0", "D57A9156ABA86C35", "7E1643B77D8188E9",
                "2B8DBCFA672FBA30", "B1A5F8D36E596780", "213247E4C982C275", "462390120F22A79E", "471EFB0E00D50AB7", "51D1351F3DB0A879", "3898597D54411BEB", "2CE081AE2511FDB4", "53014FDB0FDF4DD4", "BDD950D5E932248A", "CE370683075CAC94", "96A6D08551E4BD53", "FF37FCF60671DDE2", "C476899350C351BB", "3E4D53B3FAB07DDF", "7789E21DB66DF603", "7AA772849FD6C1E1", "9E39A4D6DCA740BC", "4BA60963FD0C28F1", "B936329B64A5CE04", "4C3A682D50A515D6", "082D0637986F4948", "91A735D1D8B550B3", "B62B8E3922517EAF", "40D29471C50AD55E", "C5CA44A98A360808", "6C94AD8D61BB65C5", "D998578D5F396D99", "595720323A39C46D", "FC62479B2E0455E4",
                "D5E8CB83ED95EEC6", "E9B625E76E1E91F3", "E68B160585E41FD0", "D44667428492EF7F", "3FD847900BC9CB21", "1027406F3385E74B", "012363BE7AF97F6C", "04AA57ADEC25A804", "CB226890754F2F34", "5CEB353222C8405C", "95EDA5D45967FB6D", "C065540669A201F7", "17E7538BD95F5CD1", "F9A6A3FDA0AB7B5E", "142D64923FCB4E17", "CC5C179013D48D7F", "2366C9C0895F3376", "8C28F0BFC128BF92", "6D157F7ADBFDB494", "45A1AE6B26A266D2", "27C837E9F7092C3E", "60B8F8A6458C2587", "F2F53C50C6A1114F", "9DE1D90FA399C904", "CDBBE6738EB11ED9", "2A62794A4202D890", "4AA4954BF85B9F82", "07C00B81DEA9E504", "76A031D0F1D8B2A8", "BFFB73FA2A17B28B",
                "A6995717E8DEDA7E", "9668B6E4D2C9EF4C", "F66852B14575D148", "560743A569D20CE7", "86FF71F1824A43EE", "D0F83DA137E4F30C", "263AF44EDBBD9413", "B74AADDC36BA40A5", "817EF42FF76DF709", "57F19A6D18488A47", "B85E10612B9FC78B", "38EB656376FCD4D3", "DA46AB2B78A5DCF6", "3BEBE752A9EF79EC", "861C53C1DBB7C1DB", "CDA8438C244C79C3", "E3133E61DC10C8B9", "5C60987A935026A9", "E8191E71B80A623F", "73286ACB264058DA"};
        //@NoUseNewKeyEx return 1;//如果没有使用这个功能，直接返回1


        for (n = 0; n < 255; n++) {
            DevicePath = j9.FindPort(n);
            if (j9.get_LastError() != 0) return (int) j9.get_LastError();
            outString = j9.EncString(EncInString[myrnd], DevicePath);
            if ((j9.get_LastError() == 0) && (outString.compareTo(EncOutString[myrnd]) == 0)) return 0;
        }
        return -92;
    }


}
